﻿using Shake.Framework.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Shake.Framework.View;
using Shake.Business.Services;
using Shake.Domain.Models;
using Shake.Framework.Context;
using Shake.Domain.Maps;
using Shake.Domain.Filters;

namespace Shake.Web.Controllers
{
    [Theme("Partial")]
    public class CertificateController : Controller
    {
        public ICertificateService CertificateService { get; set; }
        //
        // GET: /Certificate/
        public ActionResult Index(CertificateFilter filter)
        {
            if (this.IsPostRequest())
            {
                var result = CertificateService.GetCertificate(filter);
                return this.ToJson(result);
            }
            return this.Shake();
        }

        public ActionResult Save(List<Certificate> certificates)
        {
            CertificateService.SaveCertificate(certificates);
            return this.PostResult(new PostResult { Data = certificates });
        }

        public ActionResult Remove(List<Certificate> certificates)
        {
            CertificateService.RemoveCertificate(certificates);
            return this.PostResult(new PostResult());
        }
    }
}